package util

// InStringArray
func InStringArray(checkKey string, checkArray []string) bool {
	for _, key := range checkArray {
		if key == checkKey {
			return true
		}
	}
	return false
}

// IntBoolMap
type IntBoolMap map[int]bool

// UInt32BoolMap
type UInt32BoolMap map[uint32]bool

// UInt64BoolMap
type UInt64BoolMap map[uint64]bool

// StringBoolMap
type StringBoolMap map[string]bool

// IntInterfaceMap
type IntStringMap map[int]string

// UInt64StringMap
type UInt64StringMap map[uint64]string

// GetKeys
func (m IntBoolMap) GetKeys() (keys []int) {
	keys = make([]int, 0, len(m))
	for key := range m {
		keys = append(keys, key)
	}
	return
}

// GetKeys
func (m UInt32BoolMap) GetKeys() (keys []uint32) {
	keys = make([]uint32, 0, len(m))
	for key := range m {
		keys = append(keys, key)
	}
	return
}

// GetKeys
func (m UInt64BoolMap) GetKeys() (keys []uint64) {
	keys = make([]uint64, 0, len(m))
	for key := range m {
		keys = append(keys, key)
	}
	return
}

// GetKeys
func (m StringBoolMap) GetKeys() (keys []string) {
	keys = make([]string, 0, len(m))
	for key := range m {
		keys = append(keys, key)
	}
	return
}

// GetKeys
func (m IntStringMap) GetKeys() (keys []int) {
	keys = make([]int, 0, len(m))
	for key := range m {
		keys = append(keys, key)
	}
	return
}

// GetKeys
func (m UInt64StringMap) GetKeys() (keys []uint64) {
	keys = make([]uint64, 0, len(m))
	for key := range m {
		keys = append(keys, key)
	}
	return
}

// GetUniqueSlice
func GetUniqueSlice(t []uint64) []uint64 {
	d := make(map[uint64]bool)
	r := make([]uint64, 0)
	for _, i := range t {
		if !d[i] {
			d[i] = true
			r = append(r, i)
		}
	}
	return r
}
